package com.zhaopin.file;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 * @create 2019-05-20 19:30
 */
public class BigAndSmalltonewFile {

    public static void main(String[] args) throws IOException {
        //首先读取 文件大
        // 然后读取 文件小
        String bigFile = args[0];
        String smallFile = args[1];
        String writeFilePath = args[3];

        List<String> listBig = FileUtils.readLines(new File(bigFile), "utf-8");
        List<String> listSmall = FileUtils.readLines(new File(smallFile), "utf-8");

        System.out.println("big " + listBig.size());
        System.out.println("small " + listSmall.size());
        System.out.println("1");

        List<String> bigJsonList = new ArrayList<>(2);
        for (String s : listBig) {
            JSONObject jsonObject = JSON.parseObject(s);
            bigJsonList.add(jsonObject.toJSONString());
        }
        System.out.println("2");
        List<String> smallJsonList = new ArrayList<>(2);
        for (
                String s : listSmall) {
            JSONObject jsonObject = JSON.parseObject(s);
            smallJsonList.add(jsonObject.toJSONString());
        }
        System.out.println("3");
        PrintWriter printWriter = new PrintWriter(new File(writeFilePath), "utf-8");
        int i = 0;
        for (String s : bigJsonList) {
            if (!smallJsonList.contains(s)) {
                System.out.println(i + "--------" + s);
                printWriter.println(s);
            } else {
                System.out.println(i);
            }
            i++;
        }

        printWriter.flush();
        printWriter.close();
    }

}
